<div class="layui-card">
    <div class="layui-card-header layuiadmin-card-header-auto">

    </div>
    <div class="layui-card-body">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs6">
                <div class="layui-card">
                    <div class="layui-card-header"><b>今日待跟进客户</b></div>
                    <div class="layui-card-body">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <td>客户姓名</td>
                                <td>联系电话</td>
                                <td>公司名称</td>
                                <td>最近跟进时间</td>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach ($projects as $p){ ?>
                            <tr>
                                <td><?php echo $p['name']; ?></td>
                                <td><?php echo $p['phone']; ?></td>
                                <td><?php echo $p['company']; ?></td>
                                <td><?php echo $p['follow_at']; ?></td>
                            </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-card">
                    <div class="layui-card-header"><b>节点占比</b></div>
                    <div class="layui-card-body">
                        <div id="node-pie" style="width: 100%;height: 400px"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<?php
$url = yii\helpers\Url::to(['count']);
$js = <<<JS
    layui.config({
        version: '1535898708509' //为了更新 js 缓存，可忽略
    }).extend({
        echarts: 'lib/extend/echarts' ,
        echartsTheme: 'lib/extend/echartsTheme' ,
    }).use(['form','element','table', 'layer','echarts','echartsTheme'],function() {
        var form = layui.form;  
        var element = layui.element;  
        var table = layui.table;  
        var layer = layui.layer;  
        var echarts = layui.echarts;  
        var echartsTheme = layui.echartsTheme;  
        var myechart = echarts.init(document.getElementById('node-pie'),echartsTheme)
        $.post('{$url}',{},function(res) {
            if (res.code==0){
                var legend = []
                var series = []
                $.each(res.data,function(index,elem) {
                    legend.push(index);
                    series.push({
                        value:elem,
                        name:index
                    })
                })
                myechart.setOption({
                    title: {text: "各节点项目分布情况", x: "center", textStyle: {fontSize: 14}},
                    tooltip: {trigger: "item", formatter: "{a} <br/>{b} : {c} ({d}%)"},
                    legend: {orient: "vertical", x: "left", data: legend},
                    series: [{
                        name: "项目数",
                        type: "pie",
                        radius: "55%",
                        center: ["50%", "50%"],
                        data: series
                    }]                
                });
            }   
        })
        
        window.onresize = myechart.resize
        
    });
JS;
$this->registerJs($js);
